import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { JVxeTypes, JVxeColumn } from '/@/components/jeecg/JVxeTable/types';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '课程名称',
    align: 'center',
    dataIndex: 'title',
  },
  {
    title: '课程描述',
    align: 'center',
    dataIndex: 'description',
  },
  {
    title: '教师姓名',
    align: 'center',
    dataIndex: 'teachername',
  },
  {
    title: '课程图片',
    align: 'center',
    dataIndex: 'imageurl',
    customRender: render.renderImage,
  },
  {
    title: '选课人数',
    align: 'center',
    dataIndex: 'curriculavariablecount',
  },
  {
    title: '课程详情',
    align: 'center',
    dataIndex: 'coursedetail',
  },
  {
    title: '课程时长',
    align: 'center',
    dataIndex: 'courseduration',
  },
  {
    title: '课程节数',
    align: 'center',
    dataIndex: 'coursepitchnumber',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '课程名称',
    field: 'title',
    component: 'JDictSelectTag',
    componentProps: {},
    //colProps: {span: 6},
  },
  {
    label: '教师姓名',
    field: 'teachername',
    component: 'Input',
    //colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '课程名称',
    field: 'title',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: '',
    },
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入课程名称!' }];
    },
  },
  {
    label: '课程描述',
    field: 'description',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入课程描述!' }];
    },
  },
  {
    label: '教师姓名',
    field: 'teachername',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入教师姓名!' }];
    },
  },
  {
    label: '课程图片',
    field: 'imageurl',
    component: 'JImageUpload',
    componentProps: {},
  },
  {
    label: '选课人数',
    field: 'curriculavariablecount',
    component: 'InputNumber',
  },
  {
    label: '课程详情',
    field: 'coursedetail',
    component: 'JEditor',
  },
  {
    label: '课程时长',
    field: 'courseduration',
    component: 'Input',
  },
  {
    label: '课程节数',
    field: 'coursepitchnumber',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
//子表单数据
//子表表格配置
export const studyRecordColumns: JVxeColumn[] = [
  {
    title: '开始时间',
    key: 'starttime',
    type: JVxeTypes.datetime,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
    validateRules: [{ required: true, message: '${title}不能为空' }],
  },
  {
    title: '结束时间',
    key: 'endtime',
    type: JVxeTypes.datetime,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
    validateRules: [{ required: true, message: '${title}不能为空' }],
  },
  // {
  //   title: '学习状态',
  //   key: 'status',
  //   type: JVxeTypes.select,
  //   options:[],
  //   dictCode:"",
  //   width:"200px",
  //   placeholder: '请输入${title}',
  //   defaultValue:'',
  // },
  // {
  //   title: '课程名称',
  //   key: 'muCourseName',
  //   type: JVxeTypes.input,
  //   width:"200px",
  //   placeholder: '请输入${title}',
  //   defaultValue:'',
  // },
  // {
  //   title: '教师姓名',
  //   key: 'teacherName',
  //   type: JVxeTypes.input,
  //   width:"200px",
  //   placeholder: '请输入${title}',
  //   defaultValue:'',
  // },
  {
    title: '是否签到',
    key: 'isSignString',
    type: JVxeTypes.checkbox,
    customValue: ['Y', 'N'],
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
    validateRules: [{ required: true, message: '${title}不能为空' }],
  },
];
